-
Notifications
You must be signed in to change notification settings - Fork 382
Add AMP-first preview and args to validate request for Site Scanning #6615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ilable" This reverts commit 808d969.
…ate-store-url-query-var * 'develop' of github.com:ampproject/amp-wp: (67 commits) Ignore `nested-interactive` Axe rule Set appropriate node and npm versions in package.json Downgrade package-lock.json back to v1 Improve test coverage Add special case logic for gutenberg_inject_default_block_context Improve method ordering Remove needless check for filter-specific add_block_source_comments Run wrap_block_callbacks at PHP_INT_MIN Update handle_block_source_comment_replacement to handle wrappers added in wrap_block_callbacks Simplify logic in wrap_block_callbacks Bump svgo from 2.6.0 to 2.6.1 Advise to check loopback request test Simplify language for condition for what headers are looked for Bump eslint-plugin-jest from 24.4.0 to 24.4.2 Improve test coverage for get_persistent_object_cache_learn_more_action Remove absolete wp_doing_ajax filter Eliminate use of deprecated assertion Store results of page caching to reduce severity of missing a persistent object cache Explain how page cache detection is performed Improve tests for page caching ...
Plugin builds for c226596 are ready 🛎️!
|
* @see \AMP_Validation_Manager::has_cap() | ||
* @var string | ||
*/ | ||
const AMP_FIRST = 'amp-first'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the hyphenated amp-first
is used because it's intended to be user-facing.
The new amp_store
query parameter is not user-facing, and goes along with amp_validate
. So that's why I chose an underscore.
|
@delawski One more thing I expect will be useful for you:
Since the stylesheet data is by far the most massive part of the validation response, excluding it should make the screens load faster. |
It sounds really good! Stylesheet data is huge and we don't really need it for Site Scan. |
One thing to note here is that we are fetching the scannable URLs at the beginning of the Onboarding Wizard flow. They are used later in the Site Scan. I guess we should be able to override the template mode when retrieving the URLs so that we always scan against the Standard mode. |
In regards to the URLs returned by |
@delawski I suppose after this PR we could eliminate the |
9f3a80c
to
5b46ffd
Compare
5b46ffd
to
5fc2692
Compare
5fc2692
to
9f3a80c
Compare
* | ||
* @param array $sanitization_results Sanitization results. | ||
* @param int $status_code Status code. | ||
* @param array|null $last_error Last error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a thought, Instead of taking $last_error
as an argument, can we assign it in the function itself? Since, it is return value of error_get_last();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but I thought this may be preferable since it is explicit input and less reliance on global state, so it is easier to test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me.
Summary
Validate Request Args
The
amp_validate
query var has been improved so that instead of taking a singlestring
value for the nonce, it instead can be an array of args, including:nonce
(string): What will be checked againstAMP_Validation_Manager::get_amp_validate_nonce()
cache
(bool): Whether the validation results will be stored in anamp_validated_url
post.cached_if_fresh
(bool): Whether previously-stored results will be returned if there is a non-staleamp_validated_url
post for the current URL.omit_stylesheets
(bool): Whether to omit thestylesheets
key from the response.For example, attempting to get the getting results for the homepage can look like a request to the following URL:
When such a cached request is made, the response will include a new key:
The edit link here is the Validated URL screen where the results can be viewed. See #6610 (comment). Partially addresses #4979.
A
revalidated
prop is also included which indicates whether the previously-cached data was returned (iffalse
) or whether the page was re-validated (true
).AMP-first Override
The AMP plugin's default template mode is Reader Nevertheless, when doing Site Scanning we want to check the site as if Standard template mode is active, so we can check the active theme for AMP compatibility issues. In order to facilitate this, a new
amp-first
query parameter is introduced which allows an authenticated user or a validation request force Standard mode. The logic employed for this override is adopted back from the Web Stories plugin first introduced in GoogleForCreators/web-stories-wp#3621. The conditions are a bit convoluted, but much of the admin-specific logic will be able to be eliminated once we move away from classic admin screens in favor of doing more RESTful requests for validation data. See #4719 (comment).Checklist